package com.xx.ch06.demo.demo29;


import org.apache.log4j.Logger;
import org.aspectj.lang.JoinPoint;
import org.aspectj.lang.annotation.AfterThrowing;
import org.aspectj.lang.annotation.Aspect;

/**
 * @author 许欣
 * 时间：2022/4/16 15:15
 * 描述：
 */

/**
 * 使用注解实现异常抛出增强
 */
@Aspect
public class ErrorLogger {
    private static final Logger log=Logger.getLogger(ErrorLogger.class);
    @AfterThrowing(pointcut = "execution(* service.UserService.*(..))",throwing = "e")
    public void afterThrowing(JoinPoint jp,RuntimeException e){
        log.error(jp.getSignature().getName()+"方法抛出异常："+e);
    }
}
